package servlet;

import bean.Request;
import bean.Response;
import errors.HTTPMethodNotSupportException;

import java.io.IOException;
import java.io.OutputStream;

public abstract class Servlet {


    public void service(Request request ,Response response)throws HTTPMethodNotSupportException {
        throw new HTTPMethodNotSupportException("不支持");
    }

    public void init(Request request ,Response response)throws HTTPMethodNotSupportException{
        if(request == null || response == null){
            throw new  HTTPMethodNotSupportException("发生异常");
        }
    }

    public void doBefore(Request request, Response response)throws HTTPMethodNotSupportException{
        try {
            response.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public  void doGet(Request request, Response response) throws HTTPMethodNotSupportException {
       throw new HTTPMethodNotSupportException("不支持");
    }
    public  void doPost(Request request, Response response) throws HTTPMethodNotSupportException {
        throw new HTTPMethodNotSupportException("不支持");
    }
    public  void doPut(Request request, Response response) throws HTTPMethodNotSupportException{
        throw new HTTPMethodNotSupportException("不支持");
    }
    public void doDelete(Request request, Response response) throws HTTPMethodNotSupportException{
       throw new HTTPMethodNotSupportException("不支持");
    }

    public void doError(Request request ,Response response,Exception e){

    }

}
